"""Declarative base class for SQLAlchemy models."""

from __future__ import annotations

from sqlalchemy.orm import DeclarativeBase


class Base(DeclarativeBase):
    """Base class shared by all ORM models."""

    def __repr__(self) -> str:
        mapper = getattr(self, "__mapper__", None)
        if mapper is None:
            return f"{self.__class__.__name__}()"
        columns = {key: getattr(self, key) for key in mapper.c.keys()}
        attrs = ", ".join(f"{key}={value!r}" for key, value in columns.items())
        return f"{self.__class__.__name__}({attrs})"
